<template>
	<view>
		<stop isBack>
			<view slot="content">工作台</view>
		</stop>
		
		<view v-if="datas.length > 0">
			<view class="bcf pad3 mart3" v-for="parent in datas" v-show="$com.isInArray(parent.id,userIds)">
				<view class="list-style-2 mar3">{{parent.name}}</view>
				<view class="flex-r flex-wrap flex-start mart3">
					<view class="w25  c13 flcc padb3 pos-r" @tap="goto(item.action)"
					 v-show="$com.isInArray(item.id,userIds)"
					v-for="item in parent.sons">
						<view class=" wh15-15 round3 shadow flcc pos-r">
							<!-- <text class="fa fa-cubes fa-2x"></text> -->
							<view>
								<image :src="pic(item.pic)" mode="aspectFill" class="wh10-10"></image>
							</view>
						</view>
						<view class="mart1 c11">{{item.name}}</view>
							<ripple-black></ripple-black>
					</view>
				</view>
			</view>
		</view>
		<view v-if="datas.length == 0">
			<view class="mar5 pad5 tac bdda round3 bcf">暂未无权限</view>
		</view>
		
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				datas:[],
				userIds:[],
				myIsLoading:false
			}
		},
		methods: {
			
		},
		mounted() {
			let data = this.$com.getLocDataObject("workSpaceData")
			if(this.isbool(data)){
				this.myIsLoading = false
				this.log(data)
				this.log(typeof data)
				this.datas = data
			}
			let userIds = this.$com.getLocDataObject("workSpaceUserId")
			if(this.isbool(userIds)){
				this.log(userIds)
				this.log(typeof userIds)
				this.userIds = userIds
			}
			
			this.$api.get('/api/ciming/user_work_space',{},res=>{
				if(!this.$com.isbool(res.d)){
					this.$com.showToast('权限异常')
				}else{
					this.userIds = res.d
					this.$com.setLocData("workSpaceUserId",res.d)
				}
			})
			this.$api.get("/api/user/workSpaces",{},res=>{
				this.datas = res.d
				this.$com.setLocData("workSpaceData",res.d)
			})
		
		}
	}
</script>

<style>

</style>
